package com.cn.qtms.feign;

import com.cn.qtms.feign.error.KeepErrMsgConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@FeignClient(value = "qtms-auth", configuration = {KeepErrMsgConfiguration.class})
/**
 * @author zhangyang
 */
public interface Oauth2Client {

    /**
     * 获取token
     *
     * @param parameters
     * @return
     * @throws RuntimeException
     */
    @PostMapping(path = "/oauth/token")
    Map<String, Object> postAccessToken(@RequestParam Map<String, String> parameters) throws RuntimeException;

    /**
     * 校验token是否存在 需要将token去掉token_type
     *
     * @param token
     * @return
     */
    @RequestMapping(value = "/oauth/check_token", method = RequestMethod.GET)
    public Map<String, Object> checkToken(@RequestParam("token") String token);

    /**
     * removeToken
     *
     * @param accessToken
     */
    @GetMapping(path = "/remove_token")
    void removeToken(@RequestParam("access_token") String accessToken);

    /**
     * 判断token限制     * @param token
     * @return
     */
    @GetMapping("limitedToken")
     String limitedToken(@RequestParam("token") String token);

    /**
     * 添加token限制
     * @param token
     * @return
     */
    @GetMapping("checkLimited")
     Boolean checkLimited(@RequestParam("token") String token);
}
